package test

import config.MyFile
import org.apache.commons.io.FileUtils

object test2 extends MyFile {

  def main(args: Array[String]): Unit = {
    val pep = "H:\\南农油茶数据库\\new\\Coleifera/Coleifera.pep".readFileToString.split(">").tail.map { x =>
      val lines = x.split("\n")
      val gene = lines.head.split(" ").head.replace("T","G")
      gene -> lines.tail.mkString.split('.').mkString
    }.groupBy(_._1).map { x =>
      ">" + x._1 + "\n" + x._2.maxBy(_._2.length)._2
    }.mkString("\n")

    FileUtils.writeStringToFile("H:\\南农油茶数据库\\new\\Coleifera/Coleifera2.pep".toFile, pep)

  }

  def dealCamellia_lanceoleosa = {
    val pep = "H:\\南农油茶数据库\\new\\Camellia lanceoleosa/gca.cds".readFileToString.split(">").tail.map { x =>
      val lines = x.split("\n")
      val gene = lines.head.split(" ").find(_.startsWith("gene")).get.drop(5)
      gene -> lines.tail.mkString.split('.').mkString
    }.groupBy(_._1).map { x =>
      ">" + x._1 + "\n" + x._2.maxBy(_._2.length)._2
    }.mkString("\n")

    FileUtils.writeStringToFile("H:\\南农油茶数据库\\new\\Camellia lanceoleosa/Camellia_lanceoleosa.cds".toFile, pep)

  }
}
